package o;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Handler;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;
import android.widget.Toast;
import com.huawei.appgallery.festivalanimation.particle.modifiers.SizeModifier;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import VideoNetChangeDialog.d;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class emu extends evq implements OnClickListener {
    private ImageView ʻ;
    private String ʻॱ = "0";
    public TextView ʼ;
    private ImageView ʽ;
    public View ˊ;
    private String ˊॱ = "0";
    public ImageView ˋ;
    private View ˋॱ;
    public TextView ˎ;
    public TextView ˏ;
    private int ˏॱ;
    private float ͺ = SizeModifier.STABLE_STATE_SCALE;
    public DownloadButton ॱ;
    private Handler ॱˊ;
    private long ॱˋ;
    private long ॱˎ;
    private boolean ॱॱ = false;
    private Runnable ॱᐝ = new Runnable(this) {
        final /* synthetic */ emu ˎ;

        {
            this.ˎ = r1;
        }

        public void run() {
            if (this.ˎ.ᐝ.ॱˎ() || this.ˎ.ᐝ.ॱˋ()) {
                this.ˎ.ˋॱ.setVisibility(0);
            }
        }
    };
    private evn ᐝ;
    private String ᐝॱ;

    public emu(Context context) {
        super(context);
        LayoutInflater.from(context).inflate(h.ˊˈ, this, true);
        setOnClickListener(this);
        this.ʻ = (ImageView) findViewById(j.ʻʻ);
        this.ʽ = (ImageView) findViewById(j.ʽᶥ);
        this.ˋॱ = findViewById(j.ߵᐝ);
        this.ॱ = (DownloadButton) findViewById(j.ᶥᐝ);
        this.ˋ = (ImageView) findViewById(j.ʽꓸ);
        this.ˊ = findViewById(j.ˇ);
        azb.ˋ(this.ˊ);
        this.ˎ = (TextView) findViewById(j.ˇˊ);
        this.ˏ = (TextView) findViewById(j.ʾꜟ);
        this.ʼ = (TextView) findViewById(j.ㆍʼ);
        setControllerLayoutParams();
        this.ˏॱ = dgm.ˎ((Activity) getContext());
    }

    public void ˏ(evp o_evp) {
        if (o_evp != null) {
            this.ʻ.setVisibility(8);
            ˋ(this.ʽ, o_evp.ˋ());
        }
    }

    public void setControllerLayoutParams() {
        LayoutParams layoutParams = (LayoutParams) this.ʽ.getLayoutParams();
        int ʽ;
        if (azb.ˎ(this.ʽ.getContext())) {
            if (this.ͺ > 0.0f) {
                ʽ = epv.ʽ(getContext());
                layoutParams.width = (int) (((float) ʽ) / this.ͺ);
                layoutParams.height = ʽ;
                this.ʽ.setScaleType(ScaleType.CENTER_CROP);
                return;
            }
            this.ʽ.setScaleType(ScaleType.FIT_CENTER);
            layoutParams.height = -1;
            layoutParams.width = -1;
        } else if (this.ͺ > 0.0f) {
            ʽ = epv.ʽ(getContext());
            layoutParams.height = (int) (((float) ʽ) * this.ͺ);
            layoutParams.width = ʽ;
            this.ʽ.setScaleType(ScaleType.CENTER_CROP);
        } else {
            this.ʽ.setScaleType(ScaleType.FIT_CENTER);
            layoutParams.height = -1;
            layoutParams.width = -1;
        }
    }

    public void setVideoRatio(float f) {
        this.ͺ = f;
    }

    public evn ˎ() {
        return this.ᐝ;
    }

    public void setVideoPlayer(evn o_evn) {
        this.ᐝ = o_evn;
    }

    public void setImage(int i) {
    }

    public ImageView ॱ() {
        return this.ʽ;
    }

    public void ˎ(int i) {
        Logger.ˏ("VideoStreamVideoController", "onPlayStateChanged,playState: " + i);
        this.ॱॱ = false;
        switch (i) {
            case -2:
                setKeepScreenOn(true);
                evt.ˊ(this.ᐝ.ˋˋ(), this.ˏॱ);
                ʻ();
                return;
            case -1:
                ॱˎ();
                if (doo.ˊ(getContext())) {
                    this.ॱॱ = false;
                } else {
                    this.ॱॱ = true;
                }
                ʼ();
                return;
            case 1:
                this.ʽ.setVisibility(8);
                etc.ˊ(this.ᐝ.ˋˋ(), this.ˊॱ);
                return;
            case 2:
                ͺ();
                this.ʻ.setVisibility(8);
                this.ᐝ.ˏॱ();
                return;
            case 3:
                setKeepScreenOn(true);
                this.ʽ.setVisibility(8);
                ॱˎ();
                this.ʻ.setVisibility(8);
                return;
            case 4:
                ʼ();
                return;
            case 5:
                ʼ();
                return;
            case 6:
                ͺ();
                setKeepScreenOn(true);
                return;
            case 7:
                evt.ॱ(this.ᐝ.ˋˋ(), this.ᐝ.ˊˊ(), this.ˏॱ);
                ˊ(this.ᐝ.ˊˊ());
                this.ᐝ.ʻ();
                ʻ();
                return;
            default:
                return;
        }
    }

    private void ॱॱ() {
        if (this.ᐝ != null && this.ʽ != null) {
            if (TextUtils.isEmpty(this.ᐝ.ˋ())) {
                this.ʽ.setVisibility(8);
            } else {
                this.ʽ.setVisibility(0);
            }
        }
    }

    private void ʼ() {
        setKeepScreenOn(false);
        ॱˎ();
        this.ʻ.setVisibility(0);
    }

    public void ˋ(int i) {
    }

    public boolean ʽ() {
        if (!this.ᐝ.ॱᐝ() || ((VideoNetChangeDialog.ˊ() || !doo.ˊ(getContext())) && !VideoNetChangeDialog.ˎ(getContext()))) {
            if (VideoNetChangeDialog.ˊ() && VideoNetChangeDialog.ˏ(getContext()) && (this.ᐝ.ʻॱ() || this.ᐝ.ॱˎ())) {
                VideoNetChangeDialog o_evs = new VideoNetChangeDialog(getContext());
                o_evs.ˋ(new d(this) {
                    final /* synthetic */ emu ˎ;

                    {
                        this.ˎ = r1;
                    }

                    public void ˊ() {
                        this.ˎ.ˊॱ();
                    }

                    public void ॱ() {
                        if (this.ˎ.getContext() instanceof Activity) {
                            ((Activity) this.ˎ.getContext()).finish();
                        }
                    }
                });
                o_evs.ˋ();
                this.ᐝ.ॱˊ();
            }
            return false;
        }
        this.ᐝ.ʽ();
        return true;
    }

    public void ˋ() {
        setKeepScreenOn(false);
        ˊ();
    }

    public void ˊ() {
        ॱॱ();
        ॱˎ();
        this.ʻ.setVisibility(8);
    }

    private void ʻ() {
        this.ॱˋ = System.currentTimeMillis();
        this.ॱˎ = this.ᐝ.ˊᐝ();
        this.ʻॱ = "0";
        this.ˊॱ = "0";
    }

    public void ॱ(long j) {
        evt.ॱ(this.ᐝ.ˋˋ(), j, this.ˏॱ);
        ˊ(j);
        ʻ();
    }

    private void ˊ(long j) {
        if (j <= 0) {
            Logger.ˏ("VideoStreamVideoController", "length is short, can not report video end!!");
            return;
        }
        evp ˋˋ = this.ᐝ.ˋˋ();
        etd.ˏ(ˋˋ, this.ᐝॱ, String.valueOf(this.ᐝ.ˊᐝ()), this.ʻॱ);
        evt.ˎ(ˋˋ, String.valueOf(this.ॱˋ), String.valueOf(System.currentTimeMillis()), String.valueOf(this.ᐝ.ˊᐝ() - this.ॱˎ), String.valueOf(this.ᐝ.ˊˊ()));
    }

    public void ˋ(int i, int i2, String str, String str2) {
        eta.ˊ(i, i2, str, str2);
        if (this.ᐝ.ʾ()) {
            this.ˊॱ = "1";
            this.ʻॱ = "1";
            return;
        }
        this.ˊॱ = String.valueOf(i);
        this.ʻॱ = String.valueOf(i);
    }

    public int ˎ(String str) {
        return 0;
    }

    public void ˊ(String str, int i) {
    }

    public void ˏ() {
    }

    public void setPlayOutTime(long j) {
        this.ᐝॱ = String.valueOf(j);
    }

    public void ᐝ() {
    }

    public void onClick(final View view) {
        if (view != null && view.getContext() != null) {
            if (VideoNetChangeDialog.ˊ() && VideoNetChangeDialog.ˏ(view.getContext())) {
                VideoNetChangeDialog o_evs = new VideoNetChangeDialog(view.getContext());
                o_evs.ˋ(new d(this) {
                    final /* synthetic */ emu ˎ;

                    public void ˊ() {
                        this.ˎ.ˊॱ();
                    }

                    public void ॱ() {
                        if (view.getContext() instanceof Activity) {
                            ((Activity) view.getContext()).finish();
                        }
                    }
                });
                o_evs.ˋ();
                return;
            }
            ˊॱ();
        }
    }

    private void ˊॱ() {
        if (this.ᐝ.ʿ() && !this.ॱॱ) {
            Toast.makeText(getContext(), n.ـʻ, 0).show();
        } else if (this.ᐝ.ᐝॱ() || this.ᐝ.ʿ()) {
            this.ᐝ.ʻ();
        } else if (this.ᐝ.ʻॱ() || this.ᐝ.ॱˎ()) {
            this.ᐝ.ॱˊ();
        } else if (this.ᐝ.ॱᐝ()) {
            this.ᐝ.ᐝ();
        }
    }

    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        setControllerLayoutParams();
    }

    private void ͺ() {
        if (this.ˋॱ.getVisibility() != 0) {
            if (this.ॱˊ == null) {
                this.ॱˊ = new Handler();
            }
            this.ॱˊ.removeCallbacks(this.ॱᐝ);
            this.ॱˊ.postDelayed(this.ॱᐝ, 1000);
        }
    }

    private void ॱˎ() {
        if (this.ॱˊ != null) {
            this.ॱˊ.removeCallbacks(this.ॱᐝ);
        }
        this.ॱˊ = null;
        if (this.ˋॱ != null) {
            this.ˋॱ.setVisibility(8);
        }
    }
}
